/**
 * Copyright 2007 Andrea Agili <agea@users.sf.net>
 * 
 * This plugin is licensed under the Eclipse Public License:
 * http://www.eclipse.org/org/documents/epl-v10.php
 * 
 */

package org.dnd.rcp.securetexteditor;

import java.io.File;

import org.dnd.rcp.securetexteditor.ui.Activator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class SecureEditorInput implements IEditorInput {

	private File file;

	public SecureEditorInput(File file) {
		this.file = file;
	}

	public boolean exists() {
		if (file == null)
			return false;
		return file.exists();
	}

	public ImageDescriptor getImageDescriptor() {
		return AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
				"icons/lock.png");
	}

	public String getName() {
		if (file == null)
			return "";
		return file.getName();
	}

	public IPersistableElement getPersistable() {
		return null;
	}

	public String getToolTipText() {
		if (file == null)
			return "";
		return file.getAbsolutePath();
	}

	@SuppressWarnings("rawtypes")
	public Object getAdapter(Class adapter) {
		return null;
	}

	public File getFile() {
		return file;
	}

}
